package main

import (
	"context"
	"fmt"
	"github.com/redis/go-redis/v9"
	"time"
	"utilsx/db/redisUtils"

	"webFull/config"
)

func init() {
	db.RedisRdb.Conn()
}

// CreateClient https://redis.uptrace.dev/guide/go-redis.html#over-ssh

func main() {
	// 创建Redis客户端
	client := redis.NewClient(&redis.Options{
		Addr:     "192.168.20.9:6380", // Redis服务器地址
		Password: "",                  // Redis密码
		DB:       0,                   // Redis数据库编号
	})
	ctx := context.Background()
	// 设置Hash中的某个key的值
	i, err := client.HSet(ctx, "myhash", "mykey3", "myvalue1").Result()

	if err != nil {
		return
	}
	fmt.Println(i)

	client.HSet(ctx, "myhash", "mykey2", "myvalue2").Result()

	// 给Hash中的某个key设置过期时间
	result, err := client.Expire(ctx, "myhash:mykey2", 2*time.Second).Result()
	if err != nil {
		return
	}
	fmt.Println(result)

}

func test() {
	//asd := []string{"a", "as", "b", "aasds"}
	redisUtils.HashSet[string](db.RedisRdb, db.OrderCart, string("adasda"), "orderCartId")
	redisUtils.HashSet[string](db.RedisRdb, db.OrderCart, string("a1111"), "orderCartId")
	redisUtils.HashSet[string](db.RedisRdb, db.OrderCart, string("b1111"), "orderCartId")
	redisUtils.SetExpiration(db.RedisRdb, db.OrderCart+":"+"a1111", 2*time.Second)
	//redisUtils.SetExpiration(db.RedisRdb, db.OrderCart, 2*time.Second)
}

func AAAA(asd ...any) {

}
